/// 商城管理
import {ums} from '@/utils/request'
import {UmsListReq, UmsListType} from '@/type/ums'
import {
  CarouselEditType,
  CarouselListType,
  CarouselSaveType
} from '@/view/shopping/carousel/carouselType'
import {
  categoryListType,
  categorySaveType,
  categoryUpdateType
} from '@/view/shopping/category/category'
import {
  BrandIdType,
  BrandListFormType,
  BrandListResType,
  BrandSaveType,
  BrandUpdateType
} from '@/view/shopping/brand/brandType'
import {
  ColorSaveType, ColorUpdate, DiscountType, InfoListType, infoPic, pic, PicList,
  ProductDeleteType,
  ProductFormType,
  ProductIsHotType, productListType,
  ProductSaveType,
  ProductUpdateType
} from '@/view/shopping/product/productType'
import {OrderQuery, OrderTableData} from '@/view/order/order/order'
import {logisticsListType, logisticsQueryType} from '@/view/order/logistics/logisticsType'
import * as http from 'http'
// UmsListType
// UmsListReq
// 轮播图
export const ums_carousel_save = (data:CarouselSaveType) => ums.post("carousel/save", data)
export const ums_carousel_list = (data:UmsListReq<{
  carousel_name: string
}>) => ums.post<UmsListType<CarouselListType[]>>("carousel/list", data)
export const ums_carousel_update = (data:CarouselEditType) => ums.post("carousel/update", data)
export const ums_carousel_delete = (id: string | number) => ums.del("carousel/delete", {id})

// 分类
export const ums_category_save = (data:categorySaveType) => ums.post("category/save", data)
// 树查询
export const ums_category_treeList = () => ums.get<categoryListType[]>("category/treeList")
export const ums_category_delete = (params: {category_id: string}) => ums.del("category/delete", params)
export const ums_category_update = (data:categoryUpdateType) => ums.post("category/update", data)
export const ums_category_queryList = () => ums.get<categoryListType[]>("category/queryList")

//  品牌
export const ums_brand_save = (data:BrandSaveType) => ums.post("brand/save", data)
export const ums_brand_update = (data:BrandUpdateType) => ums.post("brand/update", data)
export const ums_brand_list = (data:UmsListReq<BrandListFormType>) => ums.post<UmsListType<BrandListResType[]>>("brand/list", data)
export const ums_brand_delete = (params: BrandIdType) => ums.del("brand/delete", params)
export const ums_brand_queryList = (data: {
  category_id: string
}) => ums.post<BrandUpdateType[]>("brand/queryList", data)

export const ums_product_list = (data:UmsListReq<ProductFormType>) => ums.post<UmsListType<productListType[]>>("product/list", data)
export const ums_product_isHot = (data:ProductIsHotType) => ums.post('product/isHot',data)
export const ums_product_save = (data: ProductSaveType) => ums.post("product/save", data)
export const ums_product_update = (data: {
  product: ProductUpdateType,
  infoList: InfoListType[]
  picUrls: string,
  infoPics: string
}) => ums.post("product/update", data)
export const ums_product_delete = (params: ProductDeleteType) => ums.del("product/delete", params)
export const sms_product_del = (data: {url: string}) => ums.post("product/pic/del", data)
export const sms_product_queryList = (params: {id: string}) => ums.get<{
  product: productListType,
  pics: pic[],
  infoPics: infoPic[],
  productInfos: PicList[]
}>("product/queryList", params)
// 设置折扣
export const sms_product_discount = (data: DiscountType) => ums.post("product/discount", data)


export const sms_product_color_save = (data:ColorSaveType) => ums.post("product/color/save", data)
export const sms_product_color_list = (params: {
  product_id: string
}) => ums.get<ColorUpdate[]>("product/color/queryList", params)

export const sms_product_color_update = (data:ColorUpdate) => ums.post("product/color/update", data)
export const sms_product_color_del = (params: {
  id: number
}) => ums.del("product/color/delete", params)

// 订单列表
export const sms_order_queryList = (data: OrderQuery) => ums.post<OrderTableData[]>("order/queryList", data)
// 确认发货
export const sms_order_confirm = (data:{
  order_no: string
}) => ums.post("order/confirm", data)
// 退货
export const msm_order_sales = (data) => ums.post("order/sales", data)
// 物流列表
export const sms_logistics_query = (data:logisticsQueryType) => ums.post<logisticsListType[]>("logistics/queryList", data)
export const sms_logistics_update = (data:logisticsListType) => ums.post("logistics/update", data)
